package Run_System;

public class MultiplyEquation extends  Equation {
    public MultiplyEquation(){
        constructor();
    }

    public MultiplyEquation(int left,char operator,int right,int value){
        this.left_operand = left;
        this.operator = operator;
        this.right_operand = right;
        this.value = value;
    }

    @Override
   protected int caculate(int left,int right) {
        return left * right;
    }

    @Override
    protected boolean checkEquation(int left,int right){
        int result = caculate(left,right);
        if( result <= MAX && result >= MIN)
            return  true;
        return  false;
    }

    @Override
    protected void constructor() {
        while (true) {
            int arr[] = randomNum(MAX, MIN);   //随机生成范围内两个数
            if (checkEquation(arr[0], arr[1])) { //如果两个数的计算结果在范围内，就创建算式
                this.left_operand = arr[0];
                this.right_operand = arr[1];
                this.operator = '*';
                this.value = caculate(arr[0],arr[1]);
                break;
            }
        }
    }
}
